package com.zking.frame.TL;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder;
import javax.swing.border.LineBorder;


import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.List;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;

import com.zking.frame.LYK.HomepageJframe;
import com.zking.frame.TJ.mySpace;
import com.zking.frame.ZC.CinemaFrame;
import com.zking.utils.TopGetFilmSrcDao;

import javax.swing.border.EtchedBorder;

public class Films extends JFrame implements MouseListener{

	private static final long serialVersionUID = 1L;

	private JPanel JP_top;// 顶上导航栏
	private ImageIcon ImageIcon_top;// 顶部图片
	private ImageIcon ImageIcon_center;// 中部图片
	private JPanel JP_center;// 中部
	private JLabel JL_under;//下方的图片label
	private JPanel JP_center_1;// 中部上方
	private JLabel ImageIcon_center_JL;// 中部上方图片的JLabel
	private JPanel JP_center_JP;// 中部的面板
	private JPanel JP_East_JP;// 中部左边的空白面板
	private JPanel JP_West_JP;// 中部右边的空白面板
	private JPanel JP_center_south;// 中部下方的面板
	private JPanel JP_center_south_JP;// 中部下方的面板
	private JPanel JP_center_south_left;// 中部下方的左边的面板
	private JPanel JP_center_south_left_North;//// 中部下方的左边的面板的上方
	private JPanel JP_center_south_left_sounth;// 中部下方的左边的面板的下方
	private JPanel JP_center_south_right;// 中部下方的右边的面板
	private JLabel JL_showNow;// 正在上映JLabel
	private JLabel JL_showAfter;// 即将上映
	private JLabel JL_center_right;// 中部右侧的图片JLabel
	private ImageIcon JL_center_right_img;// 中部右侧的图片
	private JScrollPane JSC_movie;// 电影的滚动面板
	private JPanel JP_movies;//滚动面板中的电影面板
	private List<JLabel> List_JL_movies;// 电影的集合
	private JLabel JL_movie1;// 中部右侧的图片JLabel
	private JLabel JL_movie2;// 中部右侧的图片JLabel
	private JLabel JL_movie3;// 中部右侧的图片JLabel
	private JLabel JL_movie4;// 中部右侧的图片JLabel
	private JLabel JL_movie5;// 中部右侧的图片JLabel
	private JLabel JL_movie6;// 中部右侧的图片JLabel
	private JLabel JL_movie7;
	private JLabel JL_movie8;
	private JLabel JL_movie9;
	private JLabel JL_movie10;
	private JLabel JL_movie11;
	private JLabel JL_movie12;
	private ImageIcon image1;
	private ImageIcon image2;
	private ImageIcon image3;
	private ImageIcon image4;
	
	private ImageIcon image5;
	private ImageIcon image6;

	private JPanel JP_south;// 下部

	private JLabel logopic;
	private JLabel city;// 选择城市
	private JLabel homepage;// 首页跳转按钮
	private JLabel film;// 影视页面跳转按钮
	private JLabel cinema;// 电影院页面调转按钮
	private JLabel personData;
	private JLabel out;
	// 中间面板

	public Films() {
		getContentPane().setLayout(new BorderLayout());// 边界布局

		// 上部图片
		ImageIcon_top = new ImageIcon(Films.class.getResource("111.png"));
		JP_top = new JPanel();
		JP_top.setLayout(null);
		JP_top.setBackground(new Color(255, 255, 255));
		JP_top.setPreferredSize(new Dimension(0, 90));
		getContentPane().add(BorderLayout.NORTH, JP_top);

		// 首页logo图片
		ImageIcon logo = new ImageIcon(Films.class.getResource("logo.png"));
		// 加图片没反应
		logopic = new JLabel(logo);
		logopic.setBounds(60, 15, 158, 69);
		JP_top.add(logopic);

		// 首页城市选择
		city = new JLabel("湘潭");
		city.setBounds(250, 25, 70, 40);
		city.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		JP_top.add(city);

		// 首页按钮
		homepage = new JLabel("首页");
		homepage.setBounds(360, 25, 70, 40);
		homepage.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		homepage.addMouseListener(this);
		JP_top.add(homepage);
		
		

		// 回到影视页面按钮
		film = new JLabel("影片");
		film.setForeground(Color.RED);
		film.setBounds(480, 25, 70, 40);
		film.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		film.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				film.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				film.setForeground(Color.red);
			}
		});
		JP_top.add(film);
		
		
		// 回到影院的按钮
		cinema = new JLabel("影院");
		cinema.setBounds(590, 25, 70, 40);
		cinema.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		cinema.addMouseListener(this);
		JP_top.add(cinema);
		// 个人中心

		personData = new JLabel("个人中心 |");
		personData.setBounds(1230, 25, 120, 40);
		personData.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		personData.addMouseListener(this);
		JP_top.add(personData);

		// 退出
		out = new JLabel("退出");
		out.setBounds(1350, 25, 70, 40);
		out.setFont(new Font("楷体", Font.CENTER_BASELINE, 20));
		out.addMouseListener(this);
		JP_top.add(out);

		// 中部
		JP_center = new JPanel();
		JP_center.setBackground(new Color(250, 250, 250));
		JP_center.setLayout(null);
		// JP_top.setPreferredSize(new Dimension(0, ImageIcon_top.getIconHeight()));
		// pl_center.setBorder(new LineBorder(Color.GRAY));
		getContentPane().add(BorderLayout.CENTER, JP_center);

		// 中部左边空白面板
		JP_East_JP = new JPanel();
		JP_East_JP.setBackground(new Color(255, 255, 255));
		JP_East_JP.setBounds(0, 0, 114, 742);
		JP_center.add(JP_East_JP);

		// 中部放一个可调整的面板
		JP_center_JP = new JPanel();
		JP_center_JP.setLayout(null);
		JP_center_JP.setBackground(new Color(255, 255, 255));
		JP_center_JP.setBorder(new LineBorder(new Color(255, 255, 255)));
		JP_center_JP.setBounds(114, 0, 1240, 742);
		JP_center.add(JP_center_JP);

		// 中部右边的空白面板
		JP_West_JP = new JPanel();
		JP_West_JP.setBackground(new Color(255, 255, 255));
		JP_West_JP.setBounds(1353, 0, 131, 742);
		JP_center.add(JP_West_JP);
		// 中部上方
		JP_center_1 = new JPanel();
		JP_center_1.setBackground(Color.white);
		JP_center_1.setBounds(0, 0, 1400, 73);
		JP_center_JP.add(JP_center_1);

		// 中部上方的图片
		ImageIcon_center = new ImageIcon(Films.class.getResource("img_center.png"));
		JP_center_1.setLayout(null);

		ImageIcon_center_JL = new JLabel(ImageIcon_center);
		ImageIcon_center_JL.setBounds(0, 0, 1267, 73);
		JP_center_1.add(ImageIcon_center_JL);

		// 中部上方的图片的下方
		JP_center_south = new JPanel();
		JP_center_south.setLayout(null);
		JP_center_south.setBackground(Color.white);
		JP_center_south.setBounds(0, 73, 1240, 659);
		JP_center_JP.add(JP_center_south);

		// 中部图片下方的JPanel
		JP_center_south_JP = new JPanel();
		// JP_center_south_JP.setBackground(new Color(78,244,55));
		JP_center_south_JP.setBounds(0, 0, 1240, 659);
		JP_center_south_JP.setLayout(null);
		JP_center_south.add(JP_center_south_JP);

		// 中部下方的左边的面板
		JP_center_south_left = new JPanel();
		JP_center_south_left.setLayout(null);
		JP_center_south_left.setBackground(new Color(255, 255, 255));
		JP_center_south_left.setBounds(0, 0, 803, 659);
		JP_center_south_JP.add(JP_center_south_left);

		// 中部下方的右边的面板
		JP_center_south_right = new JPanel();
		JP_center_south_right.setBounds(797, 0, 443, 659);
		JP_center_south_right.setLayout(null);
		JP_center_south_right.setBackground(Color.WHITE);
		JP_center_south_JP.add(JP_center_south_right);

		// 中部左边上面的JPanel
		JP_center_south_left_North = new JPanel();
		JP_center_south_left_North.setBorder(new LineBorder(new Color(128, 128, 128)));
		JP_center_south_left_North.setBounds(0, 0, 803, 70);
		JP_center_south_left_North.setBackground(new Color(255, 255, 255));
		JP_center_south_left.add(JP_center_south_left_North);
		JP_center_south_left_North.setLayout(null);

		// 中部左边的下面的面板
		JP_center_south_left_sounth = new JPanel();
		JP_center_south_left_sounth.setBounds(0, 70, 803, 607);
		JP_center_south_left_sounth.setLayout(null);
		JP_center_south_left_sounth.setBackground(new Color(255, 255, 255));
		JP_center_south_left.add(JP_center_south_left_sounth);

		// 电影滚动面板
		JSC_movie = new JScrollPane();
//		JSC_movie.setLayout(null);
		JSC_movie.setBounds(0, 0, 803, 597);
		JP_center_south_left_sounth.add(JSC_movie);
		
		//电影滚动面板中的电影面板
		JP_movies = new JPanel();
		JP_movies.setBackground(Color.WHITE);
		JP_movies.setLayout(new GridLayout(3, 4, 0, 0));
//		JP_movies.setBounds(0, 0, 803, 1000);
		JP_movies.setPreferredSize(new Dimension(803, 780));
		JSC_movie.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
//		JSC_movie.add(JP_movies);
		JSC_movie.setViewportView(JP_movies);
		
		// 电影图片--image1---image6

		image1 = new ImageIcon("imges/homepic1.png");
		image2 = new ImageIcon("imges/hoempic2.png");
		image3 = new ImageIcon("imges/homepic3.png");
		image4 = new ImageIcon("imges/homepic4.png");
		image5 = new ImageIcon("imges/homepic5.png");
		image6 = new ImageIcon("imges/filmpic1.png");
		ImageIcon image7=new ImageIcon("imges/filmpic2.png");
		ImageIcon image8=new ImageIcon("imges/filmpic3.png");
		ImageIcon image9=new ImageIcon("imges/filmpic4.png");
		ImageIcon image10=new ImageIcon("imges/filmpic5.png");
		ImageIcon image11=new ImageIcon("imges/filmpic6.png");
		ImageIcon image12=new ImageIcon("imges/filmpic7.png");
		

//		List_JL_movies = new ArrayList<JLabel>();
//		//电影动态显示循环
//		for (int i = 0; i < List_JL_movies.size(); i++) {
//			ImageIcon image000 = new ImageIcon(Films.class.getResource("movie"+(i+1)+".png"));
//			JLabel JL_movie1 = new JLabel(image000);
//			List_JL_movies.add(JL_movie1);
//		}

		// 电影1--JLable
		JL_movie1 = new JLabel(image1);
		JP_movies.add(JL_movie1);
		JL_movie1.addMouseListener(this);
		JL_movie1.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie1.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});

		JL_movie2 = new JLabel(image2);
		JP_movies.add(JL_movie2);
		JL_movie2.addMouseListener(this);
		JL_movie2.addMouseListener(new MouseAdapter() {
					
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie2.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
					
		});

		JL_movie3 = new JLabel(image3);
		JP_movies.add(JL_movie3);
		JL_movie3.addMouseListener(this);
		JL_movie3.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie3.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
					
		});
		
		
		JL_movie4 = new JLabel(image4);
		JP_movies.add(JL_movie4);
		JL_movie4.addMouseListener(this);
		JL_movie4.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie4.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
					
		});

		JL_movie5 = new JLabel(image5);
		JP_movies.add(JL_movie5);
		JL_movie5.addMouseListener(this);
		JL_movie5.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie5.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
					
		});

		JL_movie6 = new JLabel(image6);
		JP_movies.add(JL_movie6);
		JL_movie6.addMouseListener(this);
		JL_movie6.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie6.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
					
		});
		JL_movie7 = new JLabel(image7);
		JP_movies.add(JL_movie7);
		JL_movie7.addMouseListener(this);
		JL_movie7.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie7.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		JL_movie8 = new JLabel(image8);
		JP_movies.add(JL_movie8);
		JL_movie8.addMouseListener(this);
		JL_movie8.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie8.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		JL_movie9 = new JLabel(image9);
		JP_movies.add(JL_movie9);
		JL_movie9.addMouseListener(this);
		JL_movie9.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie9.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		JL_movie10 = new JLabel(image10);
		JP_movies.add(JL_movie10);
		JL_movie10.addMouseListener(this);
		JL_movie10.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie10.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		JL_movie11 = new JLabel(image11);
		JP_movies.add(JL_movie11);
		JL_movie11.addMouseListener(this);
		JL_movie11.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie11.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		JL_movie12 = new JLabel(image12);
		JP_movies.add(JL_movie12);
		JL_movie12.addMouseListener(this);
		JL_movie12.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_movie12.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
		});
		

		// 正在上映按钮
		JL_showNow = new JLabel("正在上映");
		JL_showNow.setForeground(Color.red);
		JL_showNow.setBounds(66, 19, 92, 30);
		JL_showNow.setFont(new Font("宋体", Font.BOLD, 18));
		JP_center_south_left_North.add(JL_showNow);

		JL_showNow.addMouseListener(new MouseAdapter() {

			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_showNow.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				JL_showNow.setForeground(Color.red);
				JL_showAfter.setForeground(Color.black);//鼠标移入
				
			}
			
		});

		// 即将上映按钮
		JL_showAfter = new JLabel("即将上映");
		JL_showAfter.setBounds(192, 19, 101, 30);
		JL_showAfter.setFont(new Font("宋体", Font.BOLD, 18));
		JP_center_south_left_North.add(JL_showAfter);
		
		JL_showAfter.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseEntered(MouseEvent e) {
				// TODO Auto-generated method stub
				JL_showAfter.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				JL_showNow.setForeground(Color.black);//鼠标点击
				JL_showAfter.setForeground(Color.red);
//				JL_movie1 = new JLabel(image6);
//				JL_movie1.updateUI();
			}
		});
			

		JL_center_right_img = new ImageIcon(Films.class.getResource("right_content.png"));

		// 中部右边图片
		JL_center_right = new JLabel(JL_center_right_img);
		JL_center_right.setBounds(0, 0, 443, 286);
		JP_center_south_right.add(JL_center_right);
		
		
		//下方图片
		ImageIcon underImg = new ImageIcon(Films.class.getResource("under2.png"));
		JL_under = new JLabel(underImg);
		JL_under.setBounds(2, 752, 1482, 119);
		JP_center.add(JL_under);
		JL_under.setBackground(Color.BLACK);

		setTitle("淘票票");// 标题
		setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);// 点击关闭按钮退出
		setSize(1500, 1000);// 尺寸
		setLocationRelativeTo(null);// 居中
		setVisible(true);// 可见

	}

	public static void main(String[] args) {
		new Films();
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		
		Object obj=e.getSource();
		if(obj==homepage) {
			dispose();
			new HomepageJframe();
		}
		
		else if(obj==cinema) {
			dispose();
			new CinemaFrame();
		}
		else if(obj==personData) {
			dispose();
			new mySpace();
		}
		else if(obj==out) {
			dispose();
		}
		else if(obj==JL_movie1) {
			dispose();
			new FilmContent(""+JL_movie1.getIcon());
		}
		else if(obj==JL_movie2) {
			dispose();
			new FilmContent(""+JL_movie2.getIcon());
		}
		else if(obj==JL_movie3) {
			dispose();
			new FilmContent(""+JL_movie3.getIcon());
		}
		else if(obj==JL_movie4) {
			dispose();
			new FilmContent(""+JL_movie4.getIcon());
		}
		else if(obj==JL_movie5) {
			dispose();
			new FilmContent(""+JL_movie5.getIcon());
		}
		else if(obj==JL_movie6) {
			dispose();
			new FilmContent(""+JL_movie6.getIcon());
		}
		else if(obj==JL_movie7){
			dispose();
			new FilmContent(""+JL_movie7.getIcon());
		}
		else if(obj==JL_movie8){
			dispose();
			new FilmContent(""+JL_movie8.getIcon());
		}
		else if(obj==JL_movie9){
			dispose();
			new FilmContent(""+JL_movie9.getIcon());
		}
		else if(obj==JL_movie10){
			dispose();
			new FilmContent(""+JL_movie10.getIcon());
		}
		else if(obj==JL_movie11){
			dispose();
			new FilmContent(""+JL_movie11.getIcon());
		}
		else if(obj==JL_movie12){
			dispose();
			new FilmContent(""+JL_movie12.getIcon());
		}
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		Object obj=e.getSource();
		if(obj==homepage) {
			
			homepage.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
		}
		if(obj==film) {
			film.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			}
		if(obj==cinema) {
			cinema.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
		
		}
		if(obj==personData) {
			personData.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
			
		}
		if(obj==out) {
			out.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//鼠标移入
		
		}
		
		
		}
		
	 

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}
}
